﻿@namespace MXERP.Blazor.Components
@typeparam T
@inherits DebouncedInput<T>

<CascadingValue Name="SubscribeToParentForm2" Value="@SubscribeToParentForm2" IsFixed="true">
        <MudInputControl Label="@Label"
                         Variant="@Variant"
                         HelperText="@HelperText"
                         HelperTextOnFocus="@HelperTextOnFocus"
                         CounterText="@GetCounterText()"
                         FullWidth="@FullWidth"
                         Class="@Classname"
                         Error="@HasErrors"
                         ErrorText="@GetErrorText()"
                         ErrorId="@ErrorId"
                         Disabled="@Disabled"
                         Margin="@Margin"
                         Required="@Required"
                         ForId="@FieldId">
            <InputContent>
                <CascadingValue Name="SubscribeToParentForm2" Value="false" IsFixed="true">
                    @if (_mask == null)
                    {
                        <MXERP.Blazor.Components.Input 
                            T="string"
                            @ref="InputReference"
                            @attributes="UserAttributes"
                            Label="@Label"
                            InputType="@InputType"
                            Lines="@Lines"
                            Style="@Style"
                            Variant="@Variant"
                            TextUpdateSuppression="@TextUpdateSuppression"
                            Value="@Text"
                            ValueChanged="(s) => SetTextAsync(s)"
                            Placeholder="@Placeholder"
                            Disabled="@GetDisabledState()"
                            Underline="@Underline"
                            ReadOnly="@GetReadOnlyState()"
                            MaxLength="@MaxLength"
                            IconSize="@IconSize"
                            Error="@Error"
                            ErrorId="@ErrorId"
                            Immediate="@Immediate"
                            Margin="@Margin"
                            OnInput="@OnInput"
                            OnBlur="@OnBlurredAsync"
                            OnKeyDown="@InvokeKeyDownAsync"
                            OnInternalInputChanged="OnChange"
                            OnKeyUp="@InvokeKeyUpAsync"
                            KeyDownPreventDefault="KeyDownPreventDefault"
                            KeyUpPreventDefault="KeyUpPreventDefault"
                            HideSpinButtons="true"
                            Clearable="@Clearable"
                            OnClearButtonClick="@OnClearButtonClick"
                            Pattern="@Pattern"
                            AutoSize="AutoSize"
                            ShrinkLabel="@ShrinkLabel"
                            ShowVisualiser="@(DataVisualiser != null && ShowVisualiser)"
                            DataVisualiserStyle="@(DataVisualiser != null ? "min-height: 1.1876em" : null)">
                            <DataVisualiser>
                                @DataVisualiser
                            </DataVisualiser>

                            <AdornmentStart>
                                @AdornmentStart
                            </AdornmentStart>

                            <AdornmentEnd>
                                @AdornmentEnd
                            </AdornmentEnd>
                        </MXERP.Blazor.Components.Input>
                    }
                    else
                    {
                        <MudMask @ref="_maskReference"
                             @attributes="UserAttributes"
                             Mask="@_mask"
                             InputType="@InputType"
                             Lines="@Lines"
                             Style="@Style"
                             Variant="@Variant"
                             TextUpdateSuppression="@TextUpdateSuppression"
                             Value="@Text"
                             ValueChanged="OnMaskedValueChanged"
                             Placeholder="@Placeholder"
                             Disabled=@Disabled
                             Underline="@Underline"
                             ReadOnly="@ReadOnly"
                             MaxLength="@MaxLength"
                             IconSize="@IconSize"
                             Error="@Error"
                             Immediate="@Immediate"
                             Margin="@Margin" OnBlur="@OnBlurredAsync"
                             Clearable="@Clearable"
                             OnClearButtonClick="@OnClearButtonClick"
                             Adornment="@Adornment">
                         </MudMask>
                    }
                </CascadingValue>
            </InputContent>
    </MudInputControl>
</CascadingValue>